import request from '../utils/request.js'
import apiConfig from '../config/api.js'

// 景点相关接口
export const sightApi = {
	// 获取景点列表
	getSights: (params = {}) => {
		return request({
			url: apiConfig.apiList.getSights,
			method: 'GET',
			data: params // 传递查询参数如page, pageSize, status等
		})
	},
	
	// 获取单个景点详情
	getSightDetail: (id) => {
		return request({
			url: apiConfig.apiList.getSightDetail.replace(':id', id),
			method: 'GET'
		})
	},
	
	// 创建新景点
	createSight: (data) => {
		return request({
			url: apiConfig.apiList.createSight,
			method: 'POST',
			data: data
		})
	},
	
	// 更新景点信息
	updateSight: (id, data) => {
		return request({
			url: apiConfig.apiList.updateSight.replace(':id', id),
			method: 'PUT',
			data: data
		})
	},
	
	// 删除景点
	deleteSight: (id) => {
		return request({
			url: apiConfig.apiList.deleteSight.replace(':id', id),
			method: 'DELETE'
		})
	},
	
	// 收藏景点
	favoriteSight: (id) => {
		return request({
			url: apiConfig.apiList.favoriteSight.replace(':id', id),
			method: 'POST',
			needAuth: true
		})
	},
	
	// 取消收藏景点
	unfavoriteSight: (id) => {
		return request({
			url: apiConfig.apiList.unfavoriteSight.replace(':id', id),
			method: 'DELETE',
			needAuth: true
		})
	},
	
	// 获取景点总数
	getSightsTotal: () => {
		return request({
			url: apiConfig.apiList.getSightsTotal,
			method: 'GET'
		})
	},
	
	// 获取热门景点
	getHotSights: (limit = 5) => {
		return request({
			url: apiConfig.apiList.getHotSights,
			method: 'GET',
			params: { limit: limit }
		})
	},
	
	// 获取评分最高的6个景点
	getTopRatedSights: () => {
		return request({
			url: apiConfig.apiList.getTopRatedSights,
			method: 'GET'
		})
	}
}

export default sightApi